<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>管理员</title>
</head>
<body>
    <div class="shanchu">
        <form id="delete1">
            删除账号表数据<button type="button">delete</button>
        </form>

        <form id="delete2">
            删除注册时间表数据<button type="button">delete</button>
        </form>

        <form id="delete3">
            删除登录时间表数据<button type="button">delete</button>
        </form>

        <form id="delete4">
            删除验证码表数据<button type="button">delete</button>
        </form>

        <form id="delete5">
            账号数据<button type="button">check</button>
        </form>

        
    </div>
    <pre id="output">
        删除消息
    </pre>
</body>

<script>
    document.getElementById('delete1').addEventListener("click", async function (event) {
            event.preventDefault(); // 阻止表单的默认提交行为
            document.getElementById("output").textContent = "正在删除...";

            try {
                const response = await fetch("http://124.221.110.118:3000/deleteData_ZhangHao", {
                    method: "DELETE"
                });

                if (response.ok) {
                    document.getElementById("output").textContent = "账号数据删除成功！";
                } else {
                    throw new Error("删除失败");
                }
            } catch (error) {
                console.error("请求失败", error);
                document.getElementById("output").textContent = "删除失败！";
                
            }
        });

        document.getElementById('delete2').addEventListener("click", async function (event) {
            event.preventDefault(); // 阻止表单的默认提交行为
            document.getElementById("output").textContent = "正在删除...";

            try {
                const response = await fetch("http://124.221.110.118:3000/deleteData_registerTimeOut", {
                    method: "DELETE"
                });

                if (response.ok) {
                    document.getElementById("output").textContent = "注册时间数据删除成功！";
                } else {
                    throw new Error("删除失败");
                }
            } catch (error) {
                console.error("请求失败", error);
                document.getElementById("output").textContent = "删除失败！";
                
            }
        });

        document.getElementById('delete3').addEventListener("click", async function (event) {
            event.preventDefault(); // 阻止表单的默认提交行为
            document.getElementById("output").textContent = "正在删除...";

            try {
                const response = await fetch("http://124.221.110.118:3000/deleteData_loginTimeOut", {
                    method: "DELETE"
                });

                if (response.ok) {
                    document.getElementById("output").textContent = "登录时间数据删除成功！";
                } else {
                    throw new Error("删除失败");
                }
            } catch (error) {
                console.error("请求失败", error);
                document.getElementById("output").textContent = "删除失败！";
                
            }
        });

        document.getElementById('delete4').addEventListener("click", async function (event) {
            event.preventDefault(); // 阻止表单的默认提交行为
            document.getElementById("output").textContent = "正在删除...";

            try {
                const response = await fetch("http://124.221.110.118:3000/deleteData_VerificationCodes", {
                    method: "DELETE"
                });

                if (response.ok) {
                    document.getElementById("output").textContent = "验证码数据删除成功！";
                } else {
                    throw new Error("删除失败");
                }
            } catch (error) {
                console.error("请求失败", error);
                document.getElementById("output").textContent = "删除失败！";
                
            }
        });

        document.getElementById('delete5').addEventListener("click", async function (event) {
            event.preventDefault(); // 阻止表单的默认提交行为
            document.getElementById("output").textContent = "正在查询...";

            try {
                const response = await fetch("http://124.221.110.118:3000/queryData", {
                    //method: "get"
                });

                if (response.ok) {
                    document.getElementById("output").textContent = "查询成功！";
                } else {
                    throw new Error("查询失败");
                }
            } catch (error) {
                //console.error("请求失败", error);
                //document.getElementById("output").textContent = "查询失败！";
                
            }
        });
</script>
</html>